
#pragma once

#include "ProcessList.h"
#include "PointerArray.cpp"
#include "VMPI_Lock.h"

class CCodeAcquire;
class CAcquireNode : public CLinkedNode
{
public:
	CAcquireNode(CCodeAcquire *acq, LPCSTR codeid);
	~CAcquireNode() override;

	__forceinline CCodeAcquire *getAcquirer() const { return acquirer; }
	__forceinline LPCSTR getCodeId() const { return codeId; }
protected:
	LPCSTR codeId;
	CCodeAcquire *acquirer;
};
typedef CPointerArray<CAcquireNode *> CAcquireNodeArray;

class CAcquireList : public CProcessList
{
public:
	CAcquireList();
	CAcquireNode *GetNode() override
	{
		return (CAcquireNode *)CLinkedList::GetNode();
	}
	bool addPending(CAcquireNode *pNode);
	void removePending(CAcquireNode *pNode);
	CAcquireNode *findPending(CCodeAcquire *acquire);
protected:
	CAcquireNodeArray pendAry;
	vmpi_spin_lock cs_pend;
};
